package com.api.syh56.shengyunhui.service.impl;

import com.api.syh56.shengyunhui.entity.DedicatedLines;
import com.api.syh56.shengyunhui.entity.Driver;
import com.api.syh56.shengyunhui.entity.dto.DedicatedLinesDto;
import com.api.syh56.shengyunhui.exception.BaseException;
import com.api.syh56.shengyunhui.service.AdminDedicatedLinesService;
import com.api.syh56.shengyunhui.service.DedicatedLinesService;
import com.api.syh56.shengyunhui.service.DriverService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Objects;

@Service
public class AdminDedicatedLinesServiceImpl implements AdminDedicatedLinesService {
    @Autowired
    private DedicatedLinesService dedicatedLinesService;

    @Autowired
    private DriverService driverService;

    @Override
    public Page<DedicatedLines> select(Integer pageNum, Integer pageSize) {
        Page<DedicatedLines> page = new Page<>(pageNum, pageSize);
        QueryWrapper<DedicatedLines> wrapper = new QueryWrapper<>();
        return dedicatedLinesService.page(page,wrapper);
    }

    @Override
    public void insert(DedicatedLinesDto dedicatedLinesDto) {
        dedicatedLinesService.insert(dedicatedLinesDto);
    }

    @Override
    public void update(DedicatedLinesDto dedicatedLinesDto) {
        dedicatedLinesService.updateBy(dedicatedLinesDto);
    }

    @Override
    public void delete(DedicatedLines dedicatedLines) {
        dedicatedLinesService.deleteBy(dedicatedLines);
    }

//    @Override
//    public void assign(DedicatedLines dedicatedLines) {
//        QueryWrapper<Driver> driverQueryWrapper = new QueryWrapper<>();
//        driverQueryWrapper.lambda().eq(Driver::getUid,dedicatedLines.getId());
//        Driver driver = driverService.getOne(driverQueryWrapper);
//        if (Objects.isNull(driver)) {
//            throw new BaseException("");
//        }
//    }
}
